gameblenderfandomcom-20200214-history
Using BGE Libraries
__TOC__ =General= Libraries are used by creating links to data blocks in another file. The links can be absolute by using the absolute path in the filesystem or relative by using the relative path in the filesystem relative to location of the current file. I recommend to convert all paths to relative paths before publishing the files. Otherwise the used library files might not get identified at the target system. Single Data Block Files These are data blocks that are not stored in a .blend file. This can be Python files, Image files, Soundfiles etc.. As the contain one data block only they are usually applied by referencing the external file. These kind of libraries are not marked as library within Blender. Multi Data Block Files These library files are .blend files. They are libraries when another blend file links a datablock from the file. Links are marked in Blender with the "Li" symbol. An overview of all linked libraries can be found in the Outliner under "Libraries". The follwing sections will deal with mutli data block files ony. =Linking= Linking a single data block To link a data block (e.g. an object) from a .blend file into your scene do: #Open File/Append or Link #Select the option Link (not append) #Navigate to the library file to the datablock of your choice and select it #Click Load Library Now the data block is available in your file. Make sure to reference the data block somewhere in you file before saving it. Usually Blender saves datablocks and links to datablock only if the are referenced (have an user). If you link a data block all data block that are referenced by this data block are linked too. That means if you link an object all its materials, logic, animations etc. is linked too and fully working. So you can add an animated object to your blend file, without adding the animation. This makes it ideal for level creation. Linking a group If you link an object from a library file, you can't change anything of the object. This includes the position in the scene too. This makes the object nearly unusable especially when creating levels for a game. To change the position it needs to be changed in the library file. Unfortunatly it changes the position in all other files that uses this object too. There is a way out of this problem: Assign the object to a group. You link the group rather than the object (indirect link). All referenced data blocks of the linked data block are linked too. With linking the group the object is linked. But you can't see the group in your scene. That is because the group is no visual data block. To make the objects of the group appear in the scene, you do not add the group but an instance of the group. You can add as much instances as you like. You add an instance via Add > Group instance > Groupname Each instance consists of a copy of the group's object and an empty (pivot) that acts as parent for the objects. If you want to select the objects of the group you will recognise it is not possible, only the empty gets selected. You still can't change anything on the linked objects, but the objects transform now with the pivot. When you move the pivot the objects of the group move too. As you see this makes it easy to create assets for a scene. Issue: When running the BGE the objects of the group are added together with the pivot, but the pivot and the objects do not have any relationship with each other. That means the objects do not move with the pivot nor do they know it exist. This is a little conceptual drawback and might change in future. Linking multiple groups You might have recognised that you can link only one group at the time. If you have multiple groups in a library you might want to link them all in one step. That is possible possible with a little trick: Link a scene that contains instances of the groups. All the instanciated groups are linked as well and they appear in the Add>Group instances list. *In Blender 2.49 the groups are organized by filenames + group names *In Blender 2.5x the groups are shown as searchable list. For easier identification of such scenes I recommend this naming convention: _.lib *Underline makes it appear at the top of the scene names *filename let you easily identify in which file the scene is located *.lib show it is a scene of a library (and should not be used in the BGE) I hope you can see the power of linked groups. If you want to create your own libraries follow the next tutorial. =Short Summary= *Link an object, group or a scene link it via . Make sure "Link" is enabled. *Add a group instance via Add menu To find libraries you might want to check Blenderartists.org. Category:Tutorials Category:Advanced Tutorials